<?php if ($this->description) :?>
<div class="description">
<?= $this->description?>
</div>
<?php endif ?>

<?php 

if (!$this->items || count($this->items) == 0) {
	echo "We are sorry, " . $this->username . " has not received any mentions yet.";
} else {
	$date  = "";
	foreach($this->items as $item) { 
	
		$item_date = date("F j, Y", $item['timestamp']);
		
		if ($date != $item_date) {
			$date = $item_date;
			echo "<div class='date' id='".date("YMj", $item['timestamp'])."'>$date</div>";
		}
?>		

<div class="mention" id='mention_<?= $item['id'] ?>'>
	<div class='actions'>
	<?php if ($this->admin) : ?>
		<a class='delete' href='javascript:delete_mention(<?= $item['id'] ?>);' title="Delete mention"><img src="images/01.png" /></a>
	<?php endif ?>
	</div>
	<div class="avatar">
                <?php if ($item["author_avatar"] != "") : ?>
		<img src='<?= $item["author_avatar"]; ?>' />
                <?php else : ?>
                <img src='images/book50.jpg' title='User has no avatar' />
                <?php endif ?>
	</div>
	<div class="header">
		<div class="author">
			<a href="<?= $item["author_url"]?>"><?= $item["author_name"]?></a>
		</div>
		<div class="when">
			<a href="<?= $item['url']; ?>"><?= Stuffpress_Date::ago($item['timestamp'], "j M y \\a\\t G:i T"); ?></a>
		</div>
	</div>
	<div  class="title">
		<?php 
		    $comment = strip_tags($item['entry']);
		    $comment = preg_replace("|([[:alpha:]]+://[^[:space:]]+[[:alnum:]/])|",'<a href="\\1" rel="nofollow">\\1</a>', $comment);
		    $comment = preg_replace("|@([a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+)|",'<a class="h-card" href="http://\\1" target="_blank">@<span class="p-name p-nickname">\\1</span></a>',$comment);
		    $comment = preg_replace("|@([a-zA-Z0-9\-\_]+)|",'<a href="http://twitter.com/\\1" target="_blank">@<span class="p-name p-nickname">\\1</a></a>',$comment);
		    $comment = preg_replace("|#([a-zA-Z0-9_]+)|",'<a href="tag/\\1">#\\1</a>',$comment); // add tag links					
			echo $comment;
		?>
	</div>
	<?php if ($item['source_id'] && $item['item_id']): ?>
	<div class="reply">
		in reply to <a href="<?= $this->base()->thisUrl()?>/entry/<?= $item['slug']?>"><?= substr($item['slug'], 0, 50) ?>...</a>
	</div>
	<?php endif ?>
</div>	

<?php 
	}
}
